package com.zhongkun.datahome.service.domain;

import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhongkun.datahome.service.constant.NodeStatusEnum;
import com.zhongkun.datahome.service.req.cmd.system.MiniProgramNodeSettingCmd;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 房产施工计划对象 house_build_plan
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@Data
public class HouseBuildPlan extends BaseEntity {
    @ApiModelProperty("房产id")
    private Long houseId;

    @ApiModelProperty("节点名称")
    private String nodeName;

    @ApiModelProperty("节点状态，0待完成，1已完成")
    private Integer nodeStatus;

    @JsonFormat(pattern = "yyyy-MM")
    @ApiModelProperty("开始时间")
    private Date beginDate;

    public static HouseBuildPlan of(HouseBuildPlan cmd, Long houseId) {
        HouseBuildPlan plan = new HouseBuildPlan();
        plan.setHouseId(houseId);
        plan.update(cmd);
        return plan;
    }

    public void update(HouseBuildPlan cmd) {
        this.setNodeName(cmd.getNodeName());
        this.setNodeStatus(cmd.getNodeStatus());
        this.setBeginDate(cmd.getBeginDate());
    }

    public static HouseBuildPlan of(Long houseId, MiniProgramNodeSettingCmd nodeSettingCmd) {
        HouseBuildPlan plan = new HouseBuildPlan();
        plan.setHouseId(houseId);
        plan.setNodeName(nodeSettingCmd.getNodeName());
        plan.setNodeStatus(NodeStatusEnum.NOT_COMPLETE.getCode());
        // plan.setBeginDate(new Date());
        return plan;
    }
}
